package com.enterprise.viewer.client.view;

import com.enterprise.viewer.client.presenter.MasonryPresenter;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Widget;

public class Masonry extends Composite implements MasonryPresenter.Display {

	private static MasonryUiBinder uiBinder = GWT.create(MasonryUiBinder.class);

	interface MasonryUiBinder extends UiBinder<Widget, Masonry> {
	}

	@UiField (provided=true) FlexTable table;

	public Masonry() {
		// When using provide=true, the table must be instantiated
		// BEFORE calling initWidget.
		setupTable();

		initWidget(uiBinder.createAndBindUi(this));

	}

	private void setupTable() {
		table = new FlexTable();
		table.insertRow(0);

		for(int i = 0; i < 2; i++){
			for(int j = 0; j < 2; j++){
				Gadget gadget = new Gadget();
				table.setWidget(i, j, gadget);
			}
		}

		// ...and set it's column span so that it takes up the whole row.
		//table.getFlexCellFormatter().setColSpan(1, 0, 3);
	}

	@Override
	public FlexTable getContentPane() {
		return table;
	}

	/*@UiHandler("button")
	void onClick(ClickEvent e) {
		Window.alert("Hello!");
	}*/


}
